import config from "../../config";

import url from "../utils/url";

import de from "element-ui/src/locale/lang/de";
import el from "element-ui/src/locale/lang/el";
import axios from 'axios';

export const taskinfo = {
  data() {
    return {
      // 进度汇总数据
      summaryData: [],
      // 任务进度附件
      fileList: [],
      // 进度汇总导出
      isExport: true,
      //实际完成时间
      actualFinishDate: `${new Date().getFullYear()}-${new Date().getMonth() + 1}-${new Date().getDate()}`,
      getProcessRate: "",
      remark: "",
      setqz: false,
      closed: false,
      ismodify: "",
      create: false,
      canApplyApprove: false,
      canApprove: false,
      draft: false,
      publisher: false,
      manager: false,
      joiner: false,
      completed: true,
      a: 1,
      tip: "",
      classdt: "taskmsg",
      classxx: "taskxx",
      activeName: "first",
      loadings: false,
      loadings1: false,
      tasktype: {
        type: "",
        Id: "",
      },
      treeConfig: {
        anchorPointData: [
          {
            name: "目录",
            id: "1",
            show: true,
            children: [
              {
                name: "基础信息",
                id: "2",
                children: [],
                show: true,
              },
              {
                name: "详细信息",
                id: "3",
                children: [],
                show: true,
              },
              {
                name: "相关流程",
                id: "4",
                children: [],
                show: true,
              },
              {
                name: "子任务",
                id: "5",
                children: [],
                show: true,
              },
              {
                name: "进度汇总",
                id: "6",
                children: [],
                show: true,
              },
              {
                name: "任务记录",
                id: "7",
                children: [],
                show: true,
              },
            ],
          },
        ],
        taskTreeLine: 0, //实线
        anchorPointLine: 1, //虚线
      },
      content: "",
      basicInfo: {},
      extInfo: {},
      // basicInfo: {
      //   // needShenpi:'',//是否需要审批
      //   // weightStyle:'false',//是否自动计算进度
      //   // taskFocus:"",//任务关注
      //   taskFocusIds:"",
      //   canBeCycleSource: true,
      //   tipcolor: "",
      //   tip: "",
      //   issavetask: "",
      //   cycleStart: "",
      //   cycleEnd: "",
      //   intervalTask: "",
      //   managerDepartmentname: "",
      //   managername: "",
      //   completeStyle: "",
      //   time: [],
      //   cycleTypeEnums: "",
      //   publisherId: "",
      //   manager: "",
      //   managerId: "",
      //   managerDepartment: "",
      //   // // taskType: [],
      //   taskType:"",//任务类型id
      //   taskTypeName:"",//任务名称
      //   tags:[],//任务类型枚举
      //   startDate: "",
      //   end: "",
      //   weight: "",
      //   endTime: "",
      //   level: "",
      //   maxLevel: "",
      //   warnDay: "",
      //   autoComplete: true,
      //   publishId: "",
      //   cycleType: "",
      //   publisher: "",
      //   stateId: null,
      //   state: null,
      //   approveStateId: null,
      //   approveState: null,
      //   processRateNum: 0.0,
      //   processRate: 0.0,
      //   period: null,
      //   taskId: "",
      //   superId: null,
      //   topTaskId: "",
      //   cycle: false,
      //   cycleInterval: 0,
      //   allMemberIds: null,
      //   allMembers: null,
      //   allDeptIds: null,
      //   allDept: null,
      //   title: "任务名称",
      //   richContent: "任务描述",
      //   table: "master",
      // },
      // extInfo: {
      //   // afterTask:"",//后置任务名称
      //   // afterTaskId:"",//后置任务id
      //   // approver:"",//审批人id
      //   // approverName:"",//审批人名称
      //   // approvePeopleIds:"",
      //   // promoterpeople:"",//发起人
      //   // dbTypeEnums:[],//接口返回督办类型
      //   // dbType:"",//督办type
      //   // dbTypeName:"",//选择的督办类型
      //   // taskCaseIds:"",//任务关注人
      //   // taskCaseName:"",//任务关注人名称
      //   // taskNum:'',//任务编码
      //   // duBan:"",//是否督办
      //   subReference: "",
      //   supervisename: "",
      //   joinDepartmentsname: "",
      //   joinersname: "",
      //   fieldIds: [],
      //   joinerIds: null,
      //   joiners: null,
      //   joinDepartmentIds: null,
      //   joinDepartments: null,
      //   superviseId: null,
      //   supervise: null,
      //   reportCycle: 0,
      //   importantLevelId: null,
      //   importantLevel: null,
      //   attachmentList: [],
      //   fileList: [],
      //   frontTask: null,
      //   table: "master",
      // },

      //相关流程
      processesHeader: [
        {
          key: "subject",
          label: "流程标题",
          width: 400,
          dictionaries: false,
        },
        {
          key: "colWeight",
          label: "流程权重(%)",
          width: 100,
          percentage: false,
          dictionaries: false,
        },
        {
          key: "process",
          label: "流程进度(%)",
          width: 150,
          progress: true,
          percentage: false,
          dictionaries: false,
        },
        {
          key: "templateName",
          label: "模板名称",
          dictionaries: false,
        },
      ],
      processesOperation: [
        { label: "发起流程", key: "send", icon: "el-icon-upload", show: true },
        {
          label: "查看模板",
          key: "detail",
          icon: "el-icon-position",
          show: true,
        },
        {
          label: "查看流程",
          key: "detailPrco",
          icon: "el-icon-position",
          show: true,
        },
        {
          label: "编辑",
          key: "update",
          icon: "el-icon-edit-outline",
          show: true,
        },
        {
          label: "修改权重",
          key: "updateWeight",
          icon: "el-icon-position",
          show: true,
        },
        { label: "删除", key: "delete", icon: "el-icon-delete", show: true },
      ],

      templateHeader: [
        {
          key: "name",
          label: "模板名称",
          width: "120px",
          dictionaries: false,
        },
        {
          key: "url",
          label: "地址",
          width: "120px",
          dictionaries: false,
        },
      ],

      templateConfig: {
        inputWidth: "50px",
        type: ["应用分类", "模板分类"],
        templateType: [
          { label: "分类1", value: "flow" },
          { label: "分类2", value: "unflow" },
        ],
      },
      //子任务列表头配置
      subTaskHeader: [
        {
          key: "state",
          label: "状态",
          color: true,
          dictionaries: false,
        },
        {
          key: "title",
          label: "名称",
          dictionaries: false,
        },
        {
          key: "manager",
          label: "负责人",
          dictionaries: false,
        },
        {
          key: "processRate",
          label: "进度(%)",
          percentage: false,
          progress: true,
          dictionaries: false,
        },
        {
          key: "weight",
          label: "权重(%)",
          percentage: true,
          dictionaries: false,
        },
        {
          key: "taskDate",
          label: "任务时间",
          width: "200px",
          dictionaries: false,
        },
      ],
      //进度汇总列表头配置
      scheduleHeader: [
        {
          key: "dutydept",
          label: "负责部门",
          color: false,
          dictionaries: false,
        },
        {
          key: "dutymember",
          label: "负责人",
          dictionaries: false,
        },
        {
          key: "taskname",
          label: "子任务名称",
          dictionaries: false,
        },
        {
          key: "taskschedule",
          label: "进度(%)",
          percentage: false,
          progress: false,
          dictionaries: false,
        },
        {
          key: "taskstate",
          label: "任务状态",
          percentage: false,
          dictionaries: false,
        },
        {
          key: "progressnotes",
          label: "最新进度说明",
          width: "120px",
          dictionaries: false,
        },
        {
          key: "taskrelevancedocument",
          label: "相关附件",
          dictionaries: false,
        },
        {
          key: "updatedate",
          label: "更新时间",
          dictionaries: false,
        },
      ],


      subTaskOperation: [
        { label: "查看", icon: "el-icon-position" },
        { label: "删除", icon: "el-icon-delete" },
      ],

      isReply: false, //create 状态下不显示回复

      taskId: "",
      type: "",
      isBtnAuth: false,
      isBtnAuthTemp: false,
      isSave: false, //记录是否保存,
      fileUrl: []
    };
  },

  methods: {
    //修改进度
    xgjd() {
      if (this.remark == '') {
        this.$message.warning("请填写进度说明");
        return
      }
      this.loadings1 = true
      let obj1 = {
        taskId: this.basicInfo.taskId,
        processRate: this.getProcessRate,
        remark: this.remark,
        attachments: this.fileUrl.toString()
      };
      let obj2 = {
        taskId: this.basicInfo.taskId,
        processRate: this.getProcessRate,
        remark: this.remark,
        completionTime: this.actualFinishDate,
        attachments: this.fileUrl.toString()
      };
      // 判断是否有前置任务
      // 前置任务进度
      let frontTaskProcessRate = 0
      if (this.extInfo.frontTaskId) {
        
        this.$http.query(`/seeyon/rest/taskDetail/${this.extInfo.frontTaskId}?option.n_a_s=1`).then((res) => {
          console.log('前置任务信息', res)
          let { code, data } = res;
          if (code == 0) {
            frontTaskProcessRate = Math.floor(res.data.basicInfo.processRate * 100);
            console.log('前置任务进度', frontTaskProcessRate)
            if (frontTaskProcessRate !== 100) {
              console.log('前置任务进度', frontTaskProcessRate)
              if (this.getProcessRate == 100) {
                this.$message({
                  message: "前置任务进度不为100,不能修改当前任务进度为100",
                  type: "warning",
                });
                this.loadings1 = false
              }
              else {
                this.$http.post(`/seeyon/rest/taskDetail/updateProgress`, obj1).then((res) => {
                  let { code, data } = res;
                  if (code == 0) {
                    this.loadings1 = false
                    this.$message({
                      message: "进度已修改",
                      type: "success",
                    });
                    this.setqz = false;
                    this.getProcessRate = 0;
                    this.getid();
                    this.remark = ''
                    this.fileUrl = []
                    this.fileList = []
                    this.getSummaryData()
                  } else {
                    this.$message({
                      message: res.message,
                      type: "warning",
                    });
                  }
                });
              }
            }
            else {
              this.$http.post(`/seeyon/rest/taskDetail/updateProgress`, obj2).then((res) => {
                let { code, data } = res;
                if (code == 0) {
                  this.loadings1 = false
                  this.$message({
                    message: "进度已修改",
                    type: "success",
                  });
                  this.setqz = false;
                  this.getProcessRate = 0;
                  this.getid();
                  this.remark = ''
                  this.fileUrl = []
                  this.fileList = []
                  this.getSummaryData()
                } else {
                  this.$message({
                    message: res.message,
                    type: "warning",
                  });
                }
              });
            }
          }
          // _this.loadings = false;
        });
      
      }
      else {
        if (this.getProcessRate == 100) {
          this.$http.post(`/seeyon/rest/taskDetail/updateProgress`, obj2).then((res) => {
            let { code, data } = res;
            if (code == 0) {
              this.loadings1 = false
              this.$message({
                message: "进度已修改",
                type: "success",
              });
              this.setqz = false;
              this.getProcessRate = 0;
              this.getid();
              this.remark = ''
              this.fileUrl = []
              this.fileList = []
              this.getSummaryData()
            } else {
              this.$message({
                message: res.message,
                type: "warning",
              });
            }
          });
        }
        else {
          this.$http.post(`/seeyon/rest/taskDetail/updateProgress`, obj1).then((res) => {
            let { code, data } = res;
            if (code == 0) {
              this.loadings1 = false
              this.$message({
                message: "进度已修改",
                type: "success",
              });
              this.setqz = false;
              this.getProcessRate = 0;
              this.getid();
              this.remark = ''
              this.fileUrl = []
              this.fileList = []
              this.getSummaryData()
            } else {
              this.$message({
                message: res.message,
                type: "warning",
              });
            }
          });
        }
      }
    },
    // 获取进度汇总数据
    getSummaryData() {
      axios.get(`/seeyon/rest/bhtTask/getSubTask/${this.basicInfo.taskId}`).then((res) => {
        console.log('任务汇总接口调试', res)
        if (res.data.code == 200) {
          this.summaryData = res.data.data
        }
      })
    },
    showdd() {
      // console.log(this)
      // console.log(this.create || (this.publisher || this.manager &&!this.completed))
      // console.log('create'+this.create +''+ (this.publisher || this.manager &&!this.completed))
    },
    ndata() {
      this.$options.data(); // 组件初始化状态下的data对象

      Object.assign(this.$data.basicInfo, this.$options.data().basicInfo); // 重置data对象到初始化状态
      Object.assign(this.$data.extInfo, this.$options.data().extInfo); // 重置data对象到初始化状态
    },

    getcolor(state) {
      let color = "#000";
      switch (state) {
        case "进行中":
          color = "#409eff";
          break;
        case "已完成":
          color = "#004892";
          break;
        case "已超期":
          color = "#e60012";
          break;
        case "已关闭":
          color = "#909399";
          break;
        case "未开始":
          color = "#BEBEBE";
          break;
        case "预警中":
          color = "#EEAD0E";
          break;
        default:
          color = "#000";
          break;
      }
      return color;
    },
    async getid(tId) {
      this.loadings = true;
      let _this = this;
      this.isReply = false;
      //create状态下，没有选择树节点用 url.getParams('taskId') 否则使用当前选中树节点的tId
      let tid = tId ? tId : url.getParams("taskId");
      //view状态下，没有选择树节点用 this.taskId 否则使用当前选中树节点的tId
      let taskId = tId ? tId : this.taskId;

      if (this.type == "create") {
        await this.$http.query(`/seeyon/rest/bhtTask/${tid}/${top.location.href.split("isType=")[1]}?option.n_a_s=1`).then((res) => {
          let { code, data } = res;
          this.ndata();
          if (code == 0) {
            this.basicInfo = res.data.basicInfo;
            this.extInfo = res.data.extInfo;
            this.basicInfo.taskId = res.data.basicInfo.taskId;
            this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
            this.$set(this.basicInfo, "time", ['', '']);
            this.canApplyApprove = res.data.canApplyApprove;
            this.canApprove = res.data.canApprove;
            this.draft = res.data.draft;
            this.publisher = res.data.publisher;
            this.manager = res.data.manager;
            this.joiner = res.data.joiner;
            this.completed = res.data.completed;
            this.basicInfo.weight = res.data.basicInfo.weight * 100;
            this.taskId = this.basicInfo.taskId;
            this.tip = res.data.tip;
            this.basicInfo.tip = res.data.tip;
            // 新建任务和新建子任务都是默认不需要审批
            this.basicInfo.needShenpi = false

            if (JSON.parse(top.window.localStorage.getItem('taskData'))) {
              let taskData = JSON.parse(top.window.localStorage.getItem('taskData'));
              console.log('taskData', taskData)
              this.basicInfo.time = [taskData.startDate, taskData.endTime]
              this.basicInfo.richContent = taskData.richContent
              this.basicInfo.title = taskData.title
              this.extInfo.reportCycle = taskData.reportCycle
              this.basicInfo.warnDay = taskData.warnDay
              top.window.localStorage.removeItem('taskData')
            }
            this.basicInfo.weight = 100
            // 修改子任务权重及复制主任务内容到子任务
            if (window.sessionStorage.getItem('parentTitle') && window.sessionStorage.getItem('parentTime')) {
              this.basicInfo.time = window.sessionStorage.getItem('parentTime').split(',')
              if (window.sessionStorage.getItem('parentRichContent') == 'null') {
                this.basicInfo.richContent = ''
              }
              else {
                this.basicInfo.richContent = window.sessionStorage.getItem('parentRichContent')
              }
              this.basicInfo.title = window.sessionStorage.getItem('parentTitle')
              if (window.sessionStorage.getItem('reportCycle') == 'null') {
                this.extInfo.reportCycle = ''
              }
              else {
                this.extInfo.reportCycle = window.sessionStorage.getItem('reportCycle')
              }
              if (window.sessionStorage.getItem('warnDay') == 'null') {
                this.basicInfo.warnDay = ''
              }
              else {
                this.basicInfo.warnDay = window.sessionStorage.getItem('warnDay')
              }
              this.basicInfo.weight = 100
            }
            // 如果目前任务是定期任务的话 就赋值为定期任务
            // if(top.location.href.split("isType=")[1]=='dinqi'){
            //   this.basicInfo.taskType = "1739462935470099249";
            //   this.basicInfo.cycle = true
            // }
            // this.extInfo.dbTypeEnums = res.data.extInfo.dbTypeEnums;
            // this.extInfo.dbType = res.data.extInfo.dbType;
            // this.extInfo.dbTypeName = res.data.extInfo.dbTypeName;
            // this.extInfo.taskNum = res.data.extInfo.taskNum;
            // this.extInfo.afterTask = res.data.extInfo.afterTask;
            // this.extInfo.afterTaskId = res.data.extInfo.afterTaskId;
            // this.extInfo.duBan = res.data.extInfo.duBan;
            // this.basicInfo.taskType = res.data.basicInfo.taskType
            // this.basicInfo.taskTypeName = res.data.basicInfo.taskTypeName
            this.$set(this, "ismodify", true);
            this.$set(this, "create", true);
            this.$set(this.basicInfo, "canBeCycleSource", res.data.canBeCycleSource);
            this.isBtnAuth = true;
            // if (!this.joiner && !this.manager && !this.publisher) {
            //     this.isBtnAuth = true;
            // } else {
            //     this.isBtnAuth = false;
            // }
            this.isBtnAuthTemp = true;
            this.getcolor(this.basicInfo.tip);
            this.loadProcessData(-1);
            this.loadSubTask(-1);

          }
        });

        _this.loadings = false;
      } else {
        this.$http.query(`/seeyon/rest/taskDetail/${taskId}?option.n_a_s=1`).then((res) => {
          this.ndata();
          let { code, data } = res;
          if (code == 0) {
            this.$set(this, "ismodify", false);
            this.basicInfo = res.data.basicInfo;
            this.extInfo = res.data.extInfo;
            this.taskId = this.basicInfo.taskId;
            this.basicInfo.weight = res.data.basicInfo.weight * 100;
            this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);

            this.$set(this.basicInfo, "time", [this.basicInfo.startDate, this.basicInfo.endTime]);
            this.canApplyApprove = res.data.canApplyApprove;
            this.canApprove = res.data.canApprove;
            this.draft = res.data.draft;
            this.closed = res.data.closed;
            this.publisher = res.data.publisher;
            this.manager = res.data.manager;
            this.joiner = res.data.joiner;
            this.completed = res.data.completed;
            this.basicInfo.taskType = res.data.basicInfo.taskType.split(",");
            this.tip = res.data.tip;
            this.getcolor(this.basicInfo.tip);
            this.basicInfo.tip = res.data.tip;
            this.$set(this.basicInfo, "canBeCycleSource", res.data.canBeCycleSource);
            if (this.basicInfo.taskLevel == "1") {
              console.log('现在是主任务')
              this.getSummaryData()
            }

            if ((this.joiner || this.manager || this.publisher) && !this.completed) {
              this.isBtnAuth = true;
              this.isBtnAuthTemp = true;
            }

            if (this.isSave) {
              let data = this.updateTreeNode(this.treeData, this.taskId, this.basicInfo.title);
              this.treeData = data;
            }

            this.isReply = true;

            let node = this.getTreeNodeByTaskId(this.treeData, this.basicInfo.taskId);

            this.$nextTick(() => {
              this.$refs["rxTree"].setNodeColor(node);
            });
            this.loadProcessData(this.taskId);
            this.loadSubTask(this.taskId);
            if (this.extInfo.attachmentList != null) {
              this.extInfo.attachmentList.forEach((d) => {
                d.name = d.filename;
              });
            } else {
              this.extInfo.attachmentList = [];
            }

            this.$set(this.extInfo, "fileList", this.extInfo.attachmentList);
          }
          _this.loadings = false;
        });
      }
      document.getElementById("jxxs").scrollIntoView();
    },

    handleAvatarSuccess(res, file) {
      // console.log(res)
    },

    handleChange(file, fileList) {
      this.fileList = fileList.slice(-3);
    },
    increase() {
      this.basicInfo.processRate += 1;
      if (this.basicInfo.processRate > 100) {
        this.basicInfo.processRate = 100;
      }
    },
    decrease() {
      this.basicInfo.processRate -= 1;
      if (this.basicInfo.processRate < 0) {
        this.basicInfo.processRate = 0;
      }
    },

    closetask() {
      let _this = this;
      this.$confirm("确认将该任务及其子任务移动至回收站?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.loadings = true;
          this.basicInfo.endTime = this.basicInfo.time[1];
          this.basicInfo.startDate = this.basicInfo.time[0];
          this.basicInfo.processRate = this.basicInfo.processRateNum * 0.01;
          this.basicInfo.processRateNum = this.basicInfo.processRateNum * 0.01;
          this.basicInfo.weight = this.basicInfo.weight * 0.01;
          this.basicInfo.approveState = null;
          this.basicInfo.stateEnums = null;
          this.basicInfo.approveStateEnums = null;
          this.basicInfo.cycleTypeEnums = null;
          this.extInfo.importantLevelEnums = null;

          let obj = {
            basicInfo: this.basicInfo,
            extInfo: this.extInfo,
            taskColsList: [],
          };
          obj.taskId = this.taskId;
          this.$http.post(`/seeyon/rest/taskDetail/modify/7?option.n_a_s=1`, obj).then((res) => {
            _this.loadings = false;
            let { code, data } = res;
            if (code == 0) {
              this.$message({
                message: "任务已关闭",
                type: "success",
              });
              this.taskId = res.data.basicInfo.taskId;
              this.type = "view";
              this.$set(this, "ismodify", false);
              // this.initData(res.data.basicInfo.taskId)
              this.getid();
            } else {
              this.$message(res.message);
            }
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },

    retask() {
      let _this = this;
      this.$confirm("此操作将恢复该任务及其所有子任务, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        // let taskIdArr = new Array(1);
        // taskIdArr[0] = _this.taskId
        let param = {
          taskId: _this.taskId,
        };
        this.$http.post(`/seeyon/rest/taskDetail/recoveryTask`, param).then((res) => {
          let { code, data } = res;

          if (code == 0) {
            this.$message({
              message: "恢复成功",
              type: "success",
            });
            this.getid();
          } else {
            this.$message({
              message: "恢复失败",
              type: "warning",
            });
          }
        });
      });
    },
    initdata() {
      this.loadings = true;
      this.basicInfo.endTime = this.basicInfo.time[1];
      this.basicInfo.startDate = this.basicInfo.time[0];
      this.basicInfo.processRate = this.basicInfo.processRateNum * 0.01;
      this.basicInfo.processRateNum = this.basicInfo.processRateNum * 0.01;
      this.basicInfo.weight = this.basicInfo.weight * 0.01;
      this.basicInfo.approveState = null;
      this.basicInfo.stateEnums = null;
      this.basicInfo.approveStateEnums = null;
      this.basicInfo.cycleTypeEnums = null;
      this.extInfo.importantLevelEnums = null;
    },
    saveTask(n, t) {
      let issave;
      let _this = this;
      let obj = {
        basicInfo: this.basicInfo,
        extInfo: this.extInfo,
        taskColsList: [],
      };
      obj.taskId = this.taskId;
      if (obj.basicInfo.taskType == null || obj.basicInfo.taskType.length == 0) {
        obj.basicInfo.taskType = null;
      } else {
        obj.basicInfo.taskType = obj.basicInfo.taskType.toString();
      }
      if (this.type == "view") {
        if (t == 11) {
          // this.$message.warning('功能还未完成!');
          // this.loadings = false
          let _this = this;

          this.$confirm("是否停止周期任务，后续任务将不再执行!", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.initdata();
            obj.basicInfo.cycle = false;
            this.$http
              .query(`/seeyon/rest/bhtTask/cycleTask/${this.basicInfo.sourceTaskId}?opera=stop`)
              .then((res) => {
                _this.loadings = false;
                let { code, data } = res;
                if (code == 0) {
                  this.$message({
                    message: "保存成功",
                    type: "success",
                  });
                  this.taskId = res.data.basicInfo.taskId;
                  this.type = "view";
                  this.$set(this, "ismodify", false);
                  // this.initData(res.data.basicInfo.taskId)
                  this.isSave = true;
                  this.getid();
                } else {
                  this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
                  this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
                  this.basicInfo.weight = this.basicInfo.weight * 100;
                  this.$message({
                    message: res.message,
                    type: "error",
                  });
                }
              });
          });

          return;
        }
        this.initdata();

        this.$http.post(`/seeyon/rest/taskDetail/modify/${t}?option.n_a_s=1`, obj).then((res) => {
          _this.loadings = false;
          let { code, data } = res;
          if (code == 0) {
            this.$message({
              message: "保存成功",
              type: "success",
            });
            this.taskId = res.data.basicInfo.taskId;
            this.type = "view";
            this.$set(this, "ismodify", false);
            // this.initData(res.data.basicInfo.taskId)
            this.isSave = true;
            this.getid();
          } else {
            this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
            this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
            this.basicInfo.weight = this.basicInfo.weight * 100;
            this.$message(res.message);
            this.getid();
          }
        });
      } else {
        if (n == "1") {
          issave = false;
        } else if (n == "0") {
          issave = true;
        }
        this.initdata();
        if (this.basicInfo.needShenpi) {
          if (!!this.extInfo.approverName) {
            if (!!this.extInfo.duBan) {
              if (!!this.extInfo.dbType) {
                if (!!this.extInfo.supervise) {
                  this.$http.post(`/seeyon/rest/bhtTask/save/${issave}?option.n_a_s=1`, obj).then((res) => {
                    let { code, data } = res;

                    _this.loadings = false;
                    if (code == 0) {
                      this.$message({
                        message: "保存成功",
                        type: "success",
                      });

                      this.taskId = res.data.basicInfo.taskId;

                      this.type = "view";
                      this.isReply = true; //显示回复
                      this.showPointTree(this.type);
                      this.$set(this, "ismodify", false);
                      //刷新tree
                      this.refreshTreeNode(res.data.basicInfo.superId);

                      this.getid();
                    } else {
                      this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
                      this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
                      this.basicInfo.weight = this.basicInfo.weight * 100;
                      this.$message({
                        message: res.message,
                        type: "error",
                      });
                    }
                  });
                }
                else {
                  this.loadings = false;
                  this.$message({
                    message: '任务跟踪为空，请选择。',
                    type: "error",
                  });
                }
              }
              else {
                this.loadings = false;
                this.$message({
                  message: '督办类型为空，请选择。',
                  type: "error",
                });
              }
            }
            else {
              this.$http.post(`/seeyon/rest/bhtTask/save/${issave}?option.n_a_s=1`, obj).then((res) => {
                let { code, data } = res;

                _this.loadings = false;
                if (code == 0) {
                  this.$message({
                    message: "保存成功",
                    type: "success",
                  });

                  this.taskId = res.data.basicInfo.taskId;

                  this.type = "view";
                  this.isReply = true; //显示回复
                  this.showPointTree(this.type);
                  this.$set(this, "ismodify", false);
                  //刷新tree
                  this.refreshTreeNode(res.data.basicInfo.superId);

                  this.getid();
                } else {
                  this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
                  this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
                  this.basicInfo.weight = this.basicInfo.weight * 100;
                  this.$message({
                    message: res.message,
                    type: "error",
                  });
                }
              });
            }
          }
          else {
            this.loadings = false;
            this.$message({
              message: '审批人为空，请选择。',
              type: "error",
            });
          }
        }
        else {
          if (!!this.extInfo.duBan) {
            if (!!this.extInfo.dbType) {
              if (!!this.extInfo.supervise) {
                this.$http.post(`/seeyon/rest/bhtTask/save/${issave}?option.n_a_s=1`, obj).then((res) => {
                  let { code, data } = res;

                  _this.loadings = false;
                  if (code == 0) {
                    this.$message({
                      message: "保存成功",
                      type: "success",
                    });

                    this.taskId = res.data.basicInfo.taskId;

                    this.type = "view";
                    this.isReply = true; //显示回复
                    this.showPointTree(this.type);
                    this.$set(this, "ismodify", false);
                    //刷新tree
                    this.refreshTreeNode(res.data.basicInfo.superId);

                    this.getid();
                  } else {
                    this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
                    this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
                    this.basicInfo.weight = this.basicInfo.weight * 100;
                    this.$message({
                      message: res.message,
                      type: "error",
                    });
                  }
                });
              }
              else {
                this.loadings = false;
                this.$message({
                  message: '任务跟踪为空，请选择。',
                  type: "error",
                });
              }
            }
            else {
              this.loadings = false;
              this.$message({
                message: '督办类型为空，请选择。',
                type: "error",
              });
            }
          }
          else {
            this.$http.post(`/seeyon/rest/bhtTask/save/${issave}?option.n_a_s=1`, obj).then((res) => {
              let { code, data } = res;

              _this.loadings = false;
              if (code == 0) {
                this.$message({
                  message: "保存成功",
                  type: "success",
                });

                this.taskId = res.data.basicInfo.taskId;

                this.type = "view";
                this.isReply = true; //显示回复
                this.showPointTree(this.type);
                this.$set(this, "ismodify", false);
                //刷新tree
                this.refreshTreeNode(res.data.basicInfo.superId);

                this.getid();
              } else {
                this.basicInfo.processRate = Math.floor(this.basicInfo.processRateNum * 100);
                this.basicInfo.processRateNum = Math.floor(this.basicInfo.processRateNum * 100);
                this.basicInfo.weight = this.basicInfo.weight * 100;
                this.$message({
                  message: res.message,
                  type: "error",
                });
              }
            });
          }
        }

      }
    },
  },
};
